package com.ymatou.query.trading.api.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetUnCommentOrderListBean;
import com.ymatou.query.trading.api.service.GetUnCommentOrderListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.constant.ECode;

/**
 * 查询买家待评价订单 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetUnCommentOrderList {
	private static GetUnCommentOrderListBean gucolbean;
	private static GetUnCommentOrderListCall gucolcall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询买家待评价订单");
	}

	@Before
	public void caseUp() {
		gucolbean = new GetUnCommentOrderListBean();
		gucolcall = new GetUnCommentOrderListCall();

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(gucolcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetUnCommentOrderList_001() {
		Logger.start(true,"查询买家待评价订单成功");
		try {
			int UserId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("买家ID:" + UserId);
			gucolbean.setBuyerId(UserId);
			int CurrentPageNum = 1;
			Logger.comment("CurrentPageNum:" + CurrentPageNum);
			gucolbean.setCurrentPageNum(CurrentPageNum);
			int PageSize = 3;
			Logger.comment("PageSize:" + PageSize);
			gucolbean.setPageSize(PageSize);
			// 发送请求
			gucolcall.setData(gucolbean);
			gucolcall.callService();
			Logger.comment("gucolcall send:" + gucolcall.getEntityString());
			Logger.comment("gucolcall response:" + gucolcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, gucolcall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG2, gucolcall.getMsg(),
			// "验证Msg");
			Logger.verifyEquals(true, gucolcall.getOrderInfoList().size() > 0, "验证查询结果长度");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetUnCommentOrderList_002() {
		Logger.start(true,"买家用户id为空");
		try {
			int UserId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			// gucolbean.setBuyerId(UserId);
			int CurrentPageNum = 1;
			Logger.comment("CurrentPageNum:" + CurrentPageNum);
			gucolbean.setCurrentPageNum(CurrentPageNum);
			int PageSize = 3;
			Logger.comment("PageSize:" + PageSize);
			gucolbean.setPageSize(PageSize);
			// 发送请求
			gucolcall.setData(gucolbean);
			gucolcall.callService();
			Logger.comment("gucolcall send:" + gucolcall.getEntityString());
			Logger.comment("gucolcall response:" + gucolcall.getReturnData());
			Logger.verifyEquals(ECode.ERROR400, gucolcall.getCode(), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetUnCommentOrderList_003() {
		Logger.start(true,"买家用户id不存在");
		try {
			int UserId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			gucolbean.setBuyerId(1);
			int CurrentPageNum = 1;
			Logger.comment("CurrentPageNum:" + CurrentPageNum);
			gucolbean.setCurrentPageNum(CurrentPageNum);
			int PageSize = 3;
			Logger.comment("PageSize:" + PageSize);
			gucolbean.setPageSize(PageSize);
			// 发送请求
			gucolcall.setData(gucolbean);
			gucolcall.callService();
			Logger.comment("gucolcall send:" + gucolcall.getEntityString());
			Logger.comment("gucolcall response:" + gucolcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, gucolcall.getCode(), "验证Code");
			Logger.verifyEquals(0, gucolcall.getOrderInfoList().size(), "订单数量");
			Logger.verifyEquals(0, gucolcall.getRecordCount(), "验证总记录数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}